package LawsonTransformJava.pgm;
import java.sql.*;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.io.*;
import java.lang.reflect.InvocationTargetException;

import LawsonTransformJava.xref.CrossRef;
import LawsonTransformJava.xref.XrefDedCode;
import LawsonTransformJava.xref.XrefEmployee;
import LawsonTransformJava.dao.DAOEMDedMastr;
import LawsonTransformJava.dao.DAOFactoryDB;
import LawsonTransformJava.dao.DAOFactoryOracleDB;
import LawsonTransformJava.dao.DAObject;
import LawsonTransformJava.data.TblEMDedMastr;
import LawsonTransformJava.main.ClassMain;

public class PR514 extends DAObject implements 
 DAOEMDedMastr, Runnable {
	
	TblEMDedMastr edm = new TblEMDedMastr();
	

	private XrefDedCode xDedCodes = null;
	private static XrefEmployee xEmployees = null;

	private String todayx=null;
	private int  tomorrow_as_int      = 0;
	private Date tomorrow_as_date     = null;
	private int  today_as_int      = 0;
	private Date today_as_date     = null;
	private int yesterday_as_int   = 0;
	private Date yesterday_as_date = null;
	private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");		
	private int end_date_as_int    = 0;
	private Date end_date_as_date  = null;
	private int effect_date_as_int    = 0;
	private Date effect_date_as_date  = null;	
	private String xMonth=null;
	private String xDay=null;
	private String xYear=null;
	private float next_amt =0;
	int rec_read = 0;
	int rec_error = 0;
	int rec_written = 0;
	int rec_skipped = 0;
	int rec_no_flag = 0;
	int rec_with_flag = 0;
	int rec_created = 0;
	int rec_processed = 0;
	private DecimalFormat df1 = new DecimalFormat("0.0000");

	private String newX 		   	= null;
	private String z_ded_code 	   	= null;
	private String new_ded_code    	= null;
	private String ded_to_use_orig 	= null;
	private String new_b_ded_code   = null;
	private String part_of_ded_code = null;
	private int ded_flag  			= 1;
	private int write_rec  			= 1; // 1 = write 2 = do not write
	private String old_ded_code 	= null;
	private String end_date    		= null;
	private String effect_date   	= null;
	private String ded_to_use 		= null;	
	private String ded_calc_type    = null;
	private float next_amt_0001   	=.0001f;
	
	public PR514(File output) throws SQLException {
		// initialization 
		try {
			this.output = new FileWriter(this.outputFile = output);
			init(false);
		} catch (IOException e) {
			// Could no write properties file
			System.out.println("IOException: " + e);
		}
	}

 public PR514(File output, File errFile, File errReport, boolean allowBlanks) throws SQLException {
 	// initialization 
 	try {
 		this.output = new FileWriter(this.outputFile = output);
 		this.errOutput = new FileWriter(this.errOutputFile = errFile);
		this.errReport = new PRHistReport(errReport, new Date());
 		init(allowBlanks);
 	} catch (IOException e) {
 		// Could no write properties file
 		System.out.println("IOException: " + e);
 	}
 }
 
 private void init(boolean allowBlanks) throws IOException, SQLException {
		// Set the data and xref variables
		data = DAOFactoryDB.getDAODB(true);
		xDedCodes = new XrefDedCode(allowBlanks);
		xEmployees = new XrefEmployee();
		
		errReport.setPgmName(this.getClass().getSimpleName());
/*
 * Find today's date and yesterday's date
 * 	today_as_int  	  = today's date as an integer
 *  today_as_date 	  = today's date as a date
 *  yesterday_as_int  = yesterday's date as an integer
 *  yesterday_as_date = yesterday's date as a date
 *  end_date_as_int   = end date as an integer
 *  end_date_as_date  = end date as a date
 */
					    
		
		
  	    Calendar cal = Calendar.getInstance();
	    todayx = dateFormat.format(cal.getTime());
	    today_as_date = cal.getTime();
	    today_as_int  = Integer.parseInt(todayx);

		cal.add(Calendar.DATE, -1); // subtract 1 from today's date
		todayx = dateFormat.format(cal.getTime());
	    yesterday_as_date=cal.getTime();
	    yesterday_as_int = Integer.parseInt(todayx);	

		cal.add(Calendar.DATE, +1); // add 1 to today's date
		todayx = dateFormat.format(cal.getTime());
	    tomorrow_as_date=cal.getTime();
	    tomorrow_as_int = Integer.parseInt(todayx);
	        
		
	    sqlData = "SELECT * FROM " + data.getSchema() + "." + TABLE_NAME;
	    stmtData = data.getDataStatement();	    
	    countStmtData = data.getCountStatement();
	    //Set the Date Format for output
//	    df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); 
}

public TblEMDedMastr findEMDedMastr() {
		try {
			String schemax=data.getSchema();
//			TblEMDedMastr edm = new TblEMDedMastr();
			
			sqlData = "SELECT "      + 
					schemax + TABLE_NAME  + ".COMPANY, " +
					schemax + TABLE_NAME  + ".EMPLOYEE, " +
					schemax + TABLE_NAME  + ".DED_CODE, " +
					schemax + TABLE_NAME  + ".SEQ_NBR, " +
					schemax + TABLE_NAME  + ".NEXT_AMOUNT, " +
					schemax + TABLE_NAME  + ".AMOUNT_2, " +
					schemax + TABLE_NAME  + ".EXCLUDE_AMT, " + 
					schemax + TABLE_NAME  + ".BALANCE_TYPE, " +
					schemax + TABLE_NAME  + ".BALANCE_AMT, " +
					schemax + TABLE_NAME  + ".DED_PRIORITY, " +
					schemax + TABLE_NAME  + ".EFFECT_DATE, " +
					schemax + TABLE_NAME  + ".END_DATE, " +
					schemax + TABLE_NAME  + ".ARREARS, " +
					schemax + TABLE_NAME  + ".PCT_MATCHED, " +
					schemax + TABLE_NAME  + ".MONTHLY_LIMIT, " +
					schemax + TABLE_NAME  + ".PAY_PRD_LIMIT, " +
					schemax + TABLE_NAME  + ".RES_CODE, " +
					schemax + TABLE_NAME  + ".MARITAL_STATUS, " +
					schemax + TABLE_NAME  + ".EXEMPTIONS, " +
					schemax + TABLE_NAME  + ".EXEMPT_AMOUNT, " +
					schemax + TABLE_NAME  + ".CERT_CODE, " +
					schemax + TABLE_NAME  + ".PERS_EXEMPTS, " +
					schemax + TABLE_NAME  + ".DEPEND_EXEMPTS, " +
					schemax + TABLE_NAME  + ".ADDL_EXEMPTS, " +
					schemax + TABLE_NAME  + ".ADDL_EXEMP_AMT, " +
					schemax + TABLE_NAME  + ".ADDL_TAX_CODE, " +
					schemax + TABLE_NAME  + ".ADDL_RATE, " +
					schemax + TABLE_NAME  + ".ADDL_AMOUNT, " +
					schemax + TABLE_NAME  + ".ADDL_STD_DED, " +
					schemax + TABLE_NAME  + ".EXP_DIST_CO, " +
					schemax + TABLE_NAME  + ".EXP_ACCT_UNIT, " +
					schemax + TABLE_NAME  + ".EXP_ACCOUNT, " +
					schemax + TABLE_NAME  + ".EXP_SUB_ACCT, " +
					schemax + TABLE_NAME  + ".ACR_DIST_CO, " +
					schemax + TABLE_NAME  + ".ACR_ACCT_UNIT, " +
					schemax + TABLE_NAME  + ".ACR_ACCOUNT, " +
					schemax + TABLE_NAME  + ".ACR_SUB_ACCT, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_01, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_02, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_03, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_04, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_05, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_06, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_07, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_08, " +
					schemax + TABLE_NAME  + ".DED_CYCLE_09, " +
					schemax + TABLE_NAME  + ".DED_ORDER, " +
					schemax + TABLE_NAME  + ".FORMULA_NUMBER, " +
					schemax + TABLE_NAME  + ".FILING_STATUS, " +
					schemax + TABLE_NAME  + ".LEVY_EXEMPTS, " +
					schemax + TABLE_NAME  + ".LEVY_YEAR, " +
					schemax + TABLE_NAME  + ".SUB_PRIORITY, " +
					schemax + TABLE_NAME  + ".NET_CLAIM_AMT, " +
					schemax + TABLE_NAME  + ".PRESCRIBEDAREA, " +
					schemax + TABLE_NAME  + ".STUDENT_PEN_EX, " +
					schemax + TABLE_NAME  + ".TD1_FILING_DAT, " +
					schemax + TABLE_NAME  + ".TAX_EXEMPT_FLG, " +
					schemax + TABLE_NAME  + ".AUTH_TAX_CRED, " +
					schemax + TABLE_NAME  + ".AUTH_TAX_DED, " +
					schemax + TABLE_NAME  + ".MARRIED_EQUIV, " +
					schemax + TABLE_NAME  + ".AGE_65_OVER, " +
					schemax + TABLE_NAME  + ".EMP_DISABILITY, " +
					schemax + TABLE_NAME  + ".DEP_UNDER_18, " +
					schemax + TABLE_NAME  + ".DEP_DIS_OVR_17, " +
					schemax + TABLE_NAME  + ".APPROVED_STOCK, " +
					schemax + TABLE_NAME  + ".TAX_CODE, " +
					schemax + TABLE_NAME  + ".TAX_BASIS, " +
					schemax + TABLE_NAME  + ".NI_CODE, " +
					schemax + TABLE_NAME  + ".DIRECTOR, " +
					schemax + TABLE_NAME  + ".CONTRACTED_OUT, " +
					schemax + TABLE_NAME2  + ".CASE_NUMBER, " + 
					schemax + TABLE_NAME2  + ".FILE_NUMBER, " + 				   
					schemax + TABLE_NAME2  + ".DESC, " + 
					schemax + TABLE_NAME2  + ".ARR_DED_CODE, " + 
					schemax + TABLE_NAME2  + ".ARR_SEQ_NBR, " + 
					schemax + TABLE_NAME2  + ".FEES_DED_CODE, " + 
					schemax + TABLE_NAME2  + ".FEES_SEQ_NBR, " + 
					schemax + TABLE_NAME2  + ".GARN_OBJ_ID, " +  
					schemax + TABLE_NAME2  + ".TAX_ID_CODE, " + 
					schemax + TABLE_NAME2  + ".TYPE, " + 
					schemax + TABLE_NAME2  + ".VENDOR, " + 
					schemax + TABLE_NAME2  + ".ORIG_BALANCE, " + 
					schemax + TABLE_NAME2  + ".NUM_OF_DEP, " +  
					schemax + TABLE_NAME2  + ".HEAD_OF_FAM, " + 
					schemax + TABLE_NAME2  + ".ARR_ORIG_BAL, " + 
					schemax + TABLE_NAME2  + ".OVER_12_WEEKS, " + 
					schemax + TABLE_NAME2  + ".ARR_ADD_PCT, " +  
					schemax + TABLE_NAME2  + ".FEES_OVERRIDE, " + 
					schemax + TABLE_NAME2  + ".EXEM_FORM, " + 
					schemax + TABLE_NAME2  + ".RATE_X_FED_MIN, " + 
					schemax + TABLE_NAME2  + ".FACTOR_1, " + 
					schemax + TABLE_NAME2  + ".FACTOR_2, " + 
					schemax + TABLE_NAME2  + ".FACTOR_3, " + 
					schemax + TABLE_NAME2  + ".FACTOR_4, " + 
					schemax + TABLE_NAME2  + ".SND_FAMILY, " +  
					schemax + TABLE_NAME2  + ".SND_FAM_YES, " +  
					schemax + TABLE_NAME2  + ".SND_FAM_NO, " +  
					schemax + TABLE_NAME2  + ".PCT_PER_DEP, " + 
					schemax + TABLE_NAME2  + ".CALC_TYPE, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_01, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_02, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_03, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_04, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_05, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_06, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_07, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_08, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_09, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_10, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_11, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_12, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_13, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_14, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_15, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_16, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_17, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_18, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_19, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_20, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_21, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_22, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_23, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_24, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_25, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_26, " + 
					schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_27, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_28, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_29, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_PAY_CODE_30, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_01, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_02, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_03, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_04, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_05, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_06, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_07, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_08, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_09, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_10, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_11, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_12, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_13, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_14, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_15, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_16, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_17, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_18, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_19, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_20, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_21, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_22, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_23, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_24, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_25, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_26, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_27, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_28, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_29, " + 
				 	schemax + TABLE_NAME2  + ".EXCL_DED_CODE_30, " + 
				 	schemax + TABLE_NAME2  + ".DED_ARRS_TD, " +  
				 	schemax + TABLE_NAME2  + ".EXEMPT_ARRS_TD, " +  
				 	schemax + TABLE_NAME2  + ".REMIT_TO_CODE, " +  
				 	schemax + TABLE_NAME2  + ".CHFEE_OVERRIDE, " + 
				 	schemax + TABLE_NAME2  + ".FIPS_CODE, " + 
				 	schemax + TABLE_NAME2  + ".DED_FROM_GARN " +
//				 	schemax + TABLE_NAME3  + ".CALC_TYPE AS \"Ded_calc_type\" " +		
  
				   "FROM "       + schemax + TABLE_NAME  +
				   " LEFT JOIN " + schemax + TABLE_NAME2 +
				   " ON "        + schemax + TABLE_NAME  + ".GARN_OBJ_ID" +
				   "="			 + schemax + TABLE_NAME2 + ".GARN_OBJ_ID " +
//			       "INNER JOIN " + schemax + TABLE_NAME3 + 
//				   " ON "        + schemax + TABLE_NAME  + ".DED_CODE" + 
//			       "="           + schemax + TABLE_NAME3 + ".DED_CODE"
//				   " where emdedmastr.employee = 400652";
			   " WHERE " + TABLE_NAME + ".end_date = #01/01/1700#" +
			   " or    " + TABLE_NAME + ".end_date >= #03/28/2014#" +
			   " ORDER BY " + TABLE_NAME + ".employee";

			rslt = data.getDataStatement().executeQuery(sqlData);
			rsmd = rslt.getMetaData();
			
			if (rslt.next()) {
				hasMoreRecs = true;
				edm = (TblEMDedMastr) createObject(rslt, new TblEMDedMastr());
			}
			else
				hasMoreRecs = false;
			return edm;
		} catch (SQLException e) {
		    // Could not connect to the database
			System.out.println("SQLException: " + e);
		} catch (InvocationTargetException ite) {
			System.out.println("InvocationException: " + ite);
		} catch (IllegalAccessException iae) {
			System.out.println("IllegalAccessException: " + iae);
		}
	  return null;
}

public TblEMDedMastr nextEMDedMastr() {
		try {
//			TblEMDedMastr edm = new TblEMDedMastr();
			if (rslt.next()) {
				hasMoreRecs = true;
				edm = (TblEMDedMastr) createObject(rslt, new TblEMDedMastr());
			}
			else
				hasMoreRecs = false;
			return edm;
		} catch (SQLException e) {
		    // Could not connect to the database
			System.out.println("SQLException: " + e);
		} catch (InvocationTargetException ite) {
			System.out.println("InvocationException: " + ite);
		} catch (IllegalAccessException iae) {
			System.out.println("IllegalAccessException: " + iae);
		}
	  return null;
}

	public boolean hasMore () {
	  return hasMoreRecs;
	}

public int countEMDedMastr() {
	try {
		countRecs = data.getCountStatement().executeQuery("SELECT COUNT(*) FROM " + data.getSchema() + "." + TABLE_NAME + (whereClause==null?"":whereClause));
		countRecs.next();
		return recCount=countRecs.getInt(1);
		} catch (SQLException e) {
		    // Could not connect to the database
			System.out.println("SQLException: " + e);
		}
		return 0;
}

public void setWhereClause(String where) {
	  this.whereClause = where;
}

public void run() {
//	  TblEMDedMastr edm = null;
	  
	  try {
		//Update current date/time
		System.out.println(errReport.getName() + " Start " + Report.getDateFormat().format(new Date()));

		
		edm = findEMDedMastr();		
		while (hasMore()) {
			//Increment Record Read
			errReport.addReadCnt();
			checkTranslation(edm); 
			edm = nextEMDedMastr();

		}
		//Write Record Counts
		errReport.writeRecordCounts(this.countEMDedMastr());
		
		//Update current date/time
		System.out.println(errReport.getName() + " Finish " + Report.getDateFormat().format(new Date()));
		
		//Reclaim Resources
		fileCleanup();
	} catch (IOException e) {
		// Could not write properties file
		// Could not create output file
		System.out.println("IOException: " + e);
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}

public void checkTranslation (TblEMDedMastr edm) throws IOException, ParseException {
	  
	String oldDedCode = edm.getDed_code();
	String newEmployee = null;
	
		edm.setDed_code(xDedCodes.lookupNew(edm.getDed_code()));
		xEmployees.xlate(Integer.toString(edm.getEmployee()));
		
		if (!CrossRef.isError()) {
			int dedType			= xDedCodes.getTaxBen();
			/*
		    dedType 1 = Benefit deduction attached to a future benefit plan
			dedType 2 = Deduction that will be translated and passed through to PR514 
			dedType 3 = Tax deduction - Addtl Amts updates; These were created via the HR511 flag 
						and need to be 'C'hanged not 'A'dded
			dedType 4 = Benefit deductions that are not tied to a Ben Plan and need to be created via the PR514
			*/
			
			if (dedType == 2 || dedType == 3 || dedType == 4 || dedType == 6) {
				edm.setDed_code(xDedCodes.getNew());
				//Set AddChg type to 'C'hange for Tax updates
				//  Otherwise the default for TblEMDedMastr is 'A'dd
				if (dedType ==3)
					if (edm.getAddl_amount()!=0 || edm.getAddl_exemp_amt()!=0 || edm.getAddl_exempts()!=0
							|| edm.getAddl_rate()!=0 || edm.getAddl_std_ded()!=0 || edm.getAddl_tax_code()!=0
							|| edm.getTax_exempt_flg().equals("Y")) {
						edm.setAddChgType("C");
						errReport.addWrittenCnt();
		      			output.write(writePR514Layout(edm) + "\n");			//Write record
		    			this.output.flush();
					} else {
						//Write record to err output as 'SKIP'ed
						errReport.addSkippedCnt();
						edm.setAddChgType("SKIPC");
						errOutput.write(writePR514Layout(edm) + "\n");		//Write skipped record
						this.errOutput.flush();
					}
				else {
					edm.setAddChgType("A");
					errReport.addWrittenCnt();
	      			output.write(writePR514Layout(edm) + "\n");			//Write record
	    			this.output.flush();
				}
			}	
			else if (dedType == 1) {
				//Write record to err output as 'SKIP'ed
				errReport.addSkippedCnt();
				edm.setAddChgType("SKIP");
				errOutput.write(writePR514Layout(edm) + "\n");		//Write skipped record
				this.errOutput.flush();
			}
		}
		if (CrossRef.isError()) {
			//Increment Record in Error
			errReport.addErrorCnt();
			//Write to Error File
			this.errOutput.write(writePR514Layout(edm) + "\n");
			this.errOutput.flush();
			CrossRef.resetError();
		}
}

  // TODO Remove this Procedure before production release
  public void checkTranslation_Orig (TblEMDedMastr edm) throws IOException, ParseException {
		    
		rec_read = rec_read + 1;
		rec_processed = 0;
  
		String [] newDedCde = xDedCodes.getValues(edm.getDed_code());
		newX 			= xDedCodes.getValues(edm.getDed_code())[0];
		z_ded_code   	= xDedCodes.lookupNew(edm.getDed_code());
		new_ded_code 	= xDedCodes.lookupNew(edm.getDed_code());
		ded_to_use_orig = edm.getDed_code();
		ded_flag        = xDedCodes.lookupTaxBen(edm.getDed_code());
		write_rec   	= 3; // 1 = write 2 = do not write
		old_ded_code 	= xDedCodes.xlate(edm.getDed_code());
		end_date    	= edm.getEnd_date();
		ded_calc_type   = edm.getDed_calc_type();
		ded_to_use 		= new_ded_code;
		next_amt        = edm.getNext_amount();
		
		int length = ded_to_use_orig.length();

		
		if (length == 4)
		{part_of_ded_code = ded_to_use_orig.substring (1,4);
		}
		
		if (length == 3)
		{part_of_ded_code = ded_to_use_orig.substring (1,3);
		}		
		new_b_ded_code = "B" + part_of_ded_code;
		
		
//	   set the end date
		
		if (end_date==null||end_date.equals(""))
		{end_date_as_int = 0;
		 end_date_as_date = null;}
		else
			{xMonth = end_date.substring (1, 3);
		    xDay 	= end_date.substring (4, 6);
		    xYear 	= end_date.substring (7, 11);
			String date =xYear + xMonth + xDay; 
			if (date.equals("17000101"))
				{end_date_as_int = 0;
				 end_date_as_date = null;}
			else
				{end_date_as_int = Integer.parseInt(date);
				 end_date_as_date = (Date) dateFormat.parse(date);}}

//		set the effect date
		
		if (effect_date==null||effect_date.equals(""))
		{effect_date_as_int = 0;
		 effect_date_as_date = null;}
		else
			{xMonth = effect_date.substring (1, 3);
		    xDay 	= effect_date.substring (4, 6);
		    xYear 	= effect_date.substring (7, 11);
			String date =xYear + xMonth + xDay; 
			if (date.equals("17000101"))
				{effect_date_as_int = 0;
				 effect_date_as_date = null;}
			else
				{effect_date_as_int = Integer.parseInt(date);
				 effect_date_as_date = (Date) dateFormat.parse(date);}}
		
		
// TODO remove lines below that change date	and set vendor to 100
		
		String date ="20130301"; 
		today_as_int = Integer.parseInt(date);
		today_as_date = (Date) dateFormat.parse(date);  		
		
		String date2 ="20130228"; 
		yesterday_as_int = Integer.parseInt(date2);
		yesterday_as_date = (Date) dateFormat.parse(date2); 
		
		if (edm.getGarn_obj_id() > 0 )
		{	edm.setVendor("100");
		}
			
/*
	    ded_flag 1 = Benefit deduction attached to a future benefit plan
		ded_flag 2 = Benefit deduction not attached to a future benefit plan 
		ded_flag 3 = Tax deduction 
		ded_flag 4 = Benefit deduction that will not be used going forward and will not 
		             be created in future state.
		ded_flag 5 = straight pass thru
		ded_flag 6 = Like a 2 but the future state deduction code changed to "B" 
		             prefix instead of "T"
*/	   		
			
//      If deduction type = "A" (flat amount), and all deduction cycles are
//      blank, set the next amount to .0001

		if (ded_calc_type.equals("A"))
			{ if (edm.getDed_cycle_01().equals("") &&
				  edm.getDed_cycle_02().equals("") &&
		          edm.getDed_cycle_03().equals("") &&
		    	  edm.getDed_cycle_04().equals("") &&
		    	  edm.getDed_cycle_05().equals("") &&
		    	  edm.getDed_cycle_06().equals("") &&
		    	  edm.getDed_cycle_07().equals("") &&
		    	  edm.getDed_cycle_08().equals("") &&
		    	  edm.getDed_cycle_09().equals(""))
			  {
				edm.setNext_amount(next_amt_0001);
			  }
			}  	
		    	
//      If deduction type = "A" flat amount, and deduction has an end date
//      set the next amount to .0001 and blank all the deduction cycles.

		if (ded_calc_type.equals("A") && end_date_as_int > 0)
			{ 	edm.setNext_amount(next_amt_0001);
				edm.setDed_cycle_01("");
				edm.setDed_cycle_02("");
				edm.setDed_cycle_03("");	
				edm.setDed_cycle_04("");
				edm.setDed_cycle_05("");
				edm.setDed_cycle_06("");
				edm.setDed_cycle_07("");	
				edm.setDed_cycle_08("");
				edm.setDed_cycle_09("");			
			}
			 		
//      If deduction type = "A" flat amount, and deduction has no end date but
//      the next amount = 0 set the next amount to .0001 and blank all the deduction cycles
//      set the end date.

		if (ded_calc_type.equals("A")) 
		{ if (end_date_as_int == 0)
		  { if (next_amt == 0)
			{ 	edm.setNext_amount(next_amt_0001);
			    edm.setEnd_date(yesterday_as_date);
				edm.setDed_cycle_01("");
				edm.setDed_cycle_02("");
				edm.setDed_cycle_03("");	
				edm.setDed_cycle_04("");
				edm.setDed_cycle_05("");
				edm.setDed_cycle_06("");
				edm.setDed_cycle_07("");	
				edm.setDed_cycle_08("");
				edm.setDed_cycle_09("");			
			}
		  }	
		}	 				
		
//      Mark records with an end date less than the day of conversion so they are not written
		if (end_date_as_int == 0 ||
	        end_date_as_int > today_as_int)
			{rec_processed = 1;
			 write_rec = 1;}
		else
		    {write_rec = 2;
		    rec_processed = 1;
		    rec_skipped = rec_skipped + 1;
		    }
				
//		If Benefit deduction attached to a future benefit plan, skip deduction (type 1)
		
		if (write_rec == 1)
		{   if (ded_flag == 1)
            	{ rec_skipped = rec_skipped + 1;
            	  rec_processed = 1;
            	  write_rec = 2;}          		
		}
			

//     If Benefit deduction not attached to a future benefit plan (type 2)		

		
//		If Special deduction (ded_flag = 2 and has no end date:
// 		1st write a new deduction record using the translated deduction code 
//		    with an end date of yesterday.
// 		2nd write a new deduction record using the current deduction code 
//		    with a start date of today and no end date.
//		
	
		if (write_rec == 1)
		{ if (ded_flag == 2  && end_date_as_int == 0)
    		{	rec_written = rec_written + 1;
		        rec_processed = 1;
      			edm.setEnd_date(yesterday_as_date);
      			edm.setDed_code(z_ded_code);
      			edm.setDed_cycle_01("");
      			edm.setDed_cycle_02("");
      			edm.setDed_cycle_03("");	
      			edm.setDed_cycle_04("");
      			edm.setDed_cycle_05("");
      			edm.setDed_cycle_06("");
      			edm.setDed_cycle_07("");	
      			edm.setDed_cycle_08("");
      			edm.setDed_cycle_09("");					
      			output.write(writePR514Layout(edm) + "\n");		//Write historical ded with end date
      			rec_created = rec_created +1;
      			edm.setEffect_date(today_as_date);
      			edm.setEnd_date(null);
      			edm.setDed_code(ded_to_use_orig);
      			output.write(writePR514Layout(edm) + "\n");		//Write new deduction with no end date			
    		}
		}
		
//		If Special deduction (ded_flag = 2 and end date > today:
// 		1st write a new deduction record using the translated deduction code 
//		    with an end date of yesterday.
// 		2nd write a new deduction record using the current deduction code 
//		    with a start date of today and no end date.
//		
		
		if (write_rec == 1)
		{	if (ded_flag == 2  && end_date_as_int >= today_as_int)
    		{ 	rec_written = rec_written + 1;    
		        rec_processed = 1;
    			edm.setEnd_date(yesterday_as_date);
    			edm.setDed_code(z_ded_code);
    			edm.setDed_cycle_01("");
    			edm.setDed_cycle_02("");
    			edm.setDed_cycle_03("");	
    			edm.setDed_cycle_04("");
    			edm.setDed_cycle_05("");
    			edm.setDed_cycle_06("");
    			edm.setDed_cycle_07("");	
    			edm.setDed_cycle_08("");
    			edm.setDed_cycle_09("");				
    			output.write(writePR514Layout(edm) + "\n");		//Write historical ded with end date
      			rec_created = rec_created +1;
      			edm.setEffect_date(today_as_date);
    			edm.setEnd_date(null);
    			edm.setDed_code(ded_to_use_orig);
    			output.write(writePR514Layout(edm) + "\n");		//Write new deduction with no end date			
    		}	
		}
		
//		If Tax deduction (ded_flag = 3)
//	  		write a new deduction record using the translated deduction code and an 
//   		  end date of the day prior to the conversion date.
//	
		if (write_rec == 1)
		{	if (ded_flag == 3)
      		{ 	rec_written = rec_written + 1;
		        rec_processed = 1;
      			edm.setDed_code(new_ded_code);
      			edm.setEnd_date(yesterday_as_date);
      			output.write(writePR514Layout(edm) + "\n");		//Write the translated Ded_code
       		}
		}
 			
		
//		If Benefit deduction that will not be used going forward and will not be created in future state
//		  (ded_flag = 4) write a deduction record using the translated deduction code.
//
	if (write_rec == 1)
	{	if (ded_flag == 4)
  		{ 	rec_written = rec_written + 1;
	        rec_processed = 1;
  			edm.setDed_code(new_ded_code);
  			output.write(writePR514Layout(edm) + "\n");		//Write the translated Ded_code
   		}
	}
	
//	If straight pass thru (ded_flag = 5) write a deduction record as is, no translation
//	
	if (write_rec == 1)
	{	if (ded_flag == 5)
		{ 	rec_written = rec_written + 1;
	        rec_processed = 1;
			output.write(writePR514Layout(edm) + "\n");		//Write the translated Ded_code
		}
	}
		
		
//  If Like a 2 but the future state deduction code changed to "B" prefix instead of "T" (type 6)		

	
//		If Special deduction (ded_flag = 6 and has no end date:
//		1st write a new deduction record using the translated deduction code 
//		    with an end date of yesterday.
//		2nd write a new deduction record using the current deduction code with first letter changed
//		    to a "B" with a start date of today and no end date.
//		
	
		if (write_rec == 1)
		{ if (ded_flag == 6  && end_date_as_int == 0)
 		{	rec_written = rec_written + 1;    
	        rec_processed = 1;
   			edm.setEnd_date(yesterday_as_date);
   			edm.setDed_code(z_ded_code);
   			edm.setDed_cycle_01("");
   			edm.setDed_cycle_02("");
   			edm.setDed_cycle_03("");	
   			edm.setDed_cycle_04("");
   			edm.setDed_cycle_05("");
   			edm.setDed_cycle_06("");
   			edm.setDed_cycle_07("");	
   			edm.setDed_cycle_08("");
   			edm.setDed_cycle_09("");					
   			output.write(writePR514Layout(edm) + "\n");		//Write historical ded with end date
  			rec_created = rec_created +1;
  			edm.setEffect_date(today_as_date);
   			edm.setEnd_date(null);
   			edm.setDed_code(new_b_ded_code);
   			output.write(writePR514Layout(edm) + "\n");		//Write new deduction with no end date			
 		}
		}
		
//		If Special deduction (ded_flag = 2 and end date > today:
//		1st write a new deduction record using the translated deduction code 
//		    with an end date of yesterday.
//		2nd write a new deduction record using the current deduction code 
//		    with a start date of today and no end date.
//		
		
		if (write_rec == 1)
		{	if (ded_flag == 6  && end_date_as_int >= today_as_int)
 		{ 	rec_written = rec_written + 1;  
	        rec_processed = 1;
 			edm.setEnd_date(yesterday_as_date);
 			edm.setDed_code(z_ded_code);
 			edm.setDed_cycle_01("");
 			edm.setDed_cycle_02("");
 			edm.setDed_cycle_03("");	
 			edm.setDed_cycle_04("");
 			edm.setDed_cycle_05("");
 			edm.setDed_cycle_06("");
 			edm.setDed_cycle_07("");	
 			edm.setDed_cycle_08("");
 			edm.setDed_cycle_09("");				
 			output.write(writePR514Layout(edm) + "\n");		//Write historical ded with end date
  			rec_created = rec_created +1;
  			edm.setEffect_date(today_as_date);
 			edm.setEnd_date(null);
 			edm.setDed_code(new_b_ded_code);
 			output.write(writePR514Layout(edm) + "\n");		//Write new deduction with no end date			
 		}	
		}

		if (ded_flag == 0)
		{rec_skipped = rec_skipped + 1;
		 rec_no_flag = rec_no_flag + 1;
		}
		else
		{rec_with_flag = rec_with_flag +1; 
		}
		
		
		if (rec_processed == 0)
		{	
  	 System.out.println(ded_to_use_orig + " " + edm.getEnd_date() + " "  + ded_flag + 
			 		" flag: "    + rec_processed + 
			" written: " + rec_written + 
			" skipped: " + rec_skipped + " " + write_rec);
		}
		
		
  }
		

	//Output the PR514 format
	public String writePR514Layout(TblEMDedMastr edm) {

			return (
//					"\""+"A"+"\"" + "," +				// EDM-FC
					edm.getAddChgType() + "," +			// EDM-FC
					ClassMain.COMPANY + "," +
					xEmployees.xlate(Integer.toString(edm.getEmployee())) + "," +
					edm.getCase_number() + "," +		// PEG-CASE-NUMBER
					edm.getFile_number() + "," +		// PEG-FILE-NUMBER
					edm.getR_desc() + "," +				// PEG-DESC
					"\""+
					edm.getDed_code() +	    			// EDM-DED-CODE
					"\""+
					"," +	
					edm.getSeq_nbr() + "," +			// EDM-DED-SEQ-NBR
					edm.getArr_ded_code() + "," + 		// PEG-ARR-DED-CODE
					edm.getArr_seq_nbr() + "," + 		// PEG-ARR-SEQ-NBR
//					edm.getFees_ded_code() + "," + 		// PEG-FEES-DED-CODE
//					edm.getFees_seq_nbr() + "," + 		// PEG-FEES-SEQ-NBR
					edm.getGarn_obj_id()  + "," + 		// PEG-GARN-OBJ-ID
					df1.format(edm.getNext_amount()) + "," +		// EDM-NEXT-AMOUNT
					edm.getAmount_2() + "," +			// EDM-AMOUNT-2
					edm.getExclude_amt() + "," +		// EDM-EXCLUDE-AMT
					edm.getBalance_type() + "," +		// EDM-BALANCE-TYPE
					edm.getBalance_amt() + "," +		// EDM-BALANCE-AMT
//					edm.getDed_priority() + "," +		// EDM-DED-PRIORITY
					"," +								// EDM-DED-PRIORITY - Utilize the PR05 Priority
					edm.getEffect_date() + "," +		// EDM-EFFECT-DATE
					edm.getEnd_date() + "," +			// EDM-END-DATE
					edm.getArrears() + "," +			// EDM-ARREARS
					edm.getPct_matched() + "," +		// EDM-PCT-MATCHED
					edm.getMonthly_limit() + "," +		// EDM-MONTLY-LIMIT
					edm.getPay_prd_limit() + "," +		// EDM-PAY-PRD-LIMIT
					edm.getRes_code() + "," +			// EDM-RES-CODE
					edm.getMarital_status() + "," +		// EDM-MARITAL-STATUS
					edm.getExemptions() + "," +			// EDM-EXEMPTIONS
					edm.getExempt_amount() + "," +		// EDM-EXEMPT-AMOUNT
					edm.getCert_code() + "," +			// EDM-CERT-CODE
					edm.getPers_exempts() + "," +		// EDM-PERS-EXEMPTS
					edm.getDepend_exempts() + "," +		// EDM-DEPEND-EXEMPTS
					edm.getAddl_exempts() + "," +		// EDM-ADDL-EXEMPTS
					edm.getAddl_exemp_amt() + "," +		// EDM-ADDL-EXEMP-AMT
					edm.getAddl_tax_code() + "," +		// EDM-ADDL-TAX-CODE
					edm.getAddl_rate() + "," +			// EDM-ADDL-RATE
					edm.getAddl_amount() + "," +		// EDM-ADDL-AMOUNT
					edm.getAddl_std_ded() + "," +		// EDM-ADDL-STD-DED
//					edm.getExp_dist_co() + "," +		// EDM-EXP-DIST-CO
					"," +								// EDM-EXP-DIST-CO - Ignore
//					edm.getExp_acct_unit() + "," +		// EDM-EXP-ACCT-UNIT
					"," +								// EDM-EXP-ACCT-UNIT - Ignore
//					edm.getExp_account() + "," +		// EDM-EXP-ACCOUNT
					"," +								// EDM-EXP-ACCOUNT - Ignore
//					edm.getExp_sub_acct() + "," +		// EDM-EXP-SUB-ACCT
					"," +								// EDM-EXP-SUB-ACCT - Ignore
//					edm.getAcr_dist_co() + "," +		// EDM-ACR-DIST-CO
					"," +								// EDM-ACR-DIST-CO - Ignore
//					edm.getAcr_acct_unit() + "," +		// EDM-ACR-ACCT-UNIT
					"," +								// EDM-ACR-ACCT-UNIT - Ignore
//					edm.getAcr_account() + "," +		// EDM-ACR-ACCOUNT
					"," +								// EDM-ACR-ACCOUNT - Ignore
//					edm.getAcr_sub_acct() + "," +		// EDM-ACR-SUB-ACCT
					"," +								// EDM-ACR-SUB-ACCT - Ignore
//					edm.getDed_cycle_01() + "," +		// EDM-DED-CYCLE-01	
					"," +								// EDM-DED-CYCLE-01 - Ignore Cycles
//					edm.getDed_cycle_02() + "," +		// EDM-DED-CYCLE-02	
					"," +								// EDM-DED-CYCLE-02 - Ignore Cycles	
//					edm.getDed_cycle_03() + "," +		// EDM-DED-CYCLE-03	
					"," +								// EDM-DED-CYCLE-03 - Ignore Cycles	
//					edm.getDed_cycle_04() + "," +		// EDM-DED-CYCLE-04	
					"," +								// EDM-DED-CYCLE-04 - Ignore Cycles	
//					edm.getDed_cycle_05() + "," +		// EDM-DED-CYCLE-05	
					"," +								// EDM-DED-CYCLE-05 - Ignore Cycles	
//					edm.getDed_cycle_06() + "," +		// EDM-DED-CYCLE-06	
					"," +								// EDM-DED-CYCLE-06 - Ignore Cycles	
//					edm.getDed_cycle_07() + "," +		// EDM-DED-CYCLE-07	
					"," +								// EDM-DED-CYCLE-07 - Ignore Cycles	
//					edm.getDed_cycle_08() + "," +		// EDM-DED-CYCLE-08	
					"," +								// EDM-DED-CYCLE-08 - Ignore Cycles	
//					edm.getDed_cycle_09() + "," +		// EDM-DED-CYCLE-09
					"," +								// EDM-DED-CYCLE-09 - Ignore Cycles	
					edm.getDed_order()  + "," +			// EDM-DED-ORDER
					edm.getFormula_number() + "," +		// EDM-FORMULA-NUMBER
					edm.getFiling_status() + "," +		// EDM-FILING-STATUS
					edm.getLevy_exempts() + "," +		// EDM-LEVY-EXEMPTS
					edm.getLevy_year() + "," +			// EDM-LEVY-YEAR
					edm.getSub_priority() + "," +		// EDM-SUB-PRIORITY
					edm.getTax_id_code() + "," + 		// PEG-TAX-ID-CODE
					edm.getR_type() + "," +				// PEG-TYPE
//					edm.getVendor() + "," +  			// PEG-VENDOR
					"," +  								// PEG-VENDOR
					edm.getOrig_balance() + "," +		// PEG-ORIG-BALANCE
					edm.getNum_of_dep() + "," +			// PEG-NUM-OF-DEP
					edm.getHead_of_fam() + "," +		// PEG-HEAD-OF-FAM
					edm.getArr_orig_bal() + "," +		// PEG-ARR-ORIG-BAL
					edm.getOver_12_weeks() + "," +		// PEG-OVER12-WEEKS
					edm.getArr_add_pct() + "," + 		// PEG-ARR-ADD-PCT
					"," +								// PEG-ARR-NEXT-AMT - N/A
					"," +								// PEG-ARR-AMOUNT2 - N/A
					"," +								// PEG-ARR-EXCL-AMT - N/A
					"," +								// PEG-ARR-BAL-AMT - N/A
					"," +								// PEG-ARR-BAL-TYPE - N/A
					edm.getFees_override() + "," + 		// PEG-FEES-OVERRIDE
					"," +								// PEG-FEES-NEXT-AMT - N/A
					edm.getExem_form() + "," + 			// PEG-EXEM-FORM
					edm.getRate_x_fed_min() + "," +		// PEG-RATE-X-FED-MIN
					edm.getFactor_1() + "," + 			// PEG-FACTOR1
					edm.getFactor_2() + "," + 			// PEG-FACTOR2
					edm.getFactor_3() + "," +  			// PEG-FACTOR3
					edm.getFactor_4() + "," + 			// PEG-FACTOR4
					edm.getSnd_family() + "," + 		// PEG-SND-FAMILY
					edm.getSnd_fam_yes() + "," + 		// PEG-SND-FAM-YES
					edm.getSnd_fam_no() + "," + 		// PEG-SND-FAM-NO
					edm.getPct_per_dep() + "," +		// PEG-PCT-PER-DEP
					edm.getCalc_type() + "," + 			// PEG-CALC-TYPE
					edm.getExcl_pay_code_01() + "," + 	// PEG-EXCL-PAY-CODE01
					edm.getExcl_pay_code_02() + "," + 	// PEG-EXCL-PAY-CODE02					
					edm.getExcl_pay_code_03() + "," + 	// PEG-EXCL-PAY-CODE03
					edm.getExcl_pay_code_04() + "," + 	// PEG-EXCL-PAY-CODE04
					edm.getExcl_pay_code_05() + "," + 	// PEG-EXCL-PAY-CODE05
					edm.getExcl_pay_code_06() + "," + 	// PEG-EXCL-PAY-CODE06
					edm.getExcl_pay_code_07() + "," + 	// PEG-EXCL-PAY-CODE07					
					edm.getExcl_pay_code_08() + "," + 	// PEG-EXCL-PAY-CODE08
					edm.getExcl_pay_code_09() + "," + 	// PEG-EXCL-PAY-CODE09
					edm.getExcl_pay_code_10() + "," + 	// PEG-EXCL-PAY-CODE10					
					edm.getExcl_pay_code_11() + "," + 	// PEG-EXCL-PAY-CODE11
					edm.getExcl_pay_code_12() + "," + 	// PEG-EXCL-PAY-CODE12					
					edm.getExcl_pay_code_13() + "," + 	// PEG-EXCL-PAY-CODE13
					edm.getExcl_pay_code_14() + "," + 	// PEG-EXCL-PAY-CODE14
					edm.getExcl_pay_code_15() + "," + 	// PEG-EXCL-PAY-CODE15
					edm.getExcl_pay_code_16() + "," + 	// PEG-EXCL-PAY-CODE16
					edm.getExcl_pay_code_17() + "," + 	// PEG-EXCL-PAY-CODE17					
					edm.getExcl_pay_code_18() + "," + 	// PEG-EXCL-PAY-CODE18
					edm.getExcl_pay_code_19() + "," + 	// PEG-EXCL-PAY-CODE19
					edm.getExcl_pay_code_20() + "," + 	// PEG-EXCL-PAY-CODE20					
					edm.getExcl_pay_code_21() + "," + 	// PEG-EXCL-PAY-CODE21
					edm.getExcl_pay_code_22() + "," + 	// PEG-EXCL-PAY-CODE22					
					edm.getExcl_pay_code_23() + "," + 	// PEG-EXCL-PAY-CODE23
					edm.getExcl_pay_code_24() + "," + 	// PEG-EXCL-PAY-CODE24
					edm.getExcl_pay_code_25() + "," + 	// PEG-EXCL-PAY-CODE25
					edm.getExcl_pay_code_26() + "," + 	// PEG-EXCL-PAY-CODE26
					edm.getExcl_pay_code_27() + "," + 	// PEG-EXCL-PAY-CODE27					
					edm.getExcl_pay_code_28() + "," + 	// PEG-EXCL-PAY-CODE28
					edm.getExcl_pay_code_29() + "," + 	// PEG-EXCL-PAY-CODE29
					edm.getExcl_pay_code_30() + "," + 	// PEG-EXCL-PAY-CODE30
					
					//TODO These Deduction Codes should be Crosswalked if possible
					//Blanks are being used and the PR26 is updated as part of 
					//the Cutover after conversions are loaded
//					edm.getExcl_ded_code_01() + "," +	// PEG-EXCL-DED-CODE-01
//					edm.getExcl_ded_code_02() + "," +	// PEG-EXCL-DED-CODE-02					
//					edm.getExcl_ded_code_03() + "," +	// PEG-EXCL-DED-CODE-03	
//					edm.getExcl_ded_code_04() + "," +	// PEG-EXCL-DED-CODE-04		
//					edm.getExcl_ded_code_05() + "," +	// PEG-EXCL-DED-CODE-05
//					edm.getExcl_ded_code_06() + "," +	// PEG-EXCL-DED-CODE-06
//					edm.getExcl_ded_code_07() + "," +	// PEG-EXCL-DED-CODE-07					
//					edm.getExcl_ded_code_08() + "," +	// PEG-EXCL-DED-CODE-08					
//					edm.getExcl_ded_code_09() + "," +	// PEG-EXCL-DED-CODE-09					
//					edm.getExcl_ded_code_10() + "," +	// PEG-EXCL-DED-CODE-10					
//					edm.getExcl_ded_code_11() + "," +	// PEG-EXCL-DED-CODE-11
//					edm.getExcl_ded_code_12() + "," +	// PEG-EXCL-DED-CODE-12					
//					edm.getExcl_ded_code_13() + "," +	// PEG-EXCL-DED-CODE-13	
//					edm.getExcl_ded_code_14() + "," +	// PEG-EXCL-DED-CODE-14		
//					edm.getExcl_ded_code_15() + "," +	// PEG-EXCL-DED-CODE-15
//					edm.getExcl_ded_code_16() + "," +	// PEG-EXCL-DED-CODE-16
//					edm.getExcl_ded_code_17() + "," +	// PEG-EXCL-DED-CODE-17		
//					edm.getExcl_ded_code_18() + "," +	// PEG-EXCL-DED-CODE-18					
//					edm.getExcl_ded_code_19() + "," +	// PEG-EXCL-DED-CODE-19					
//					edm.getExcl_ded_code_20() + "," +	// PEG-EXCL-DED-CODE-20							
//					edm.getExcl_ded_code_21() + "," +	// PEG-EXCL-DED-CODE-21
//					edm.getExcl_ded_code_22() + "," +	// PEG-EXCL-DED-CODE-22					
//					edm.getExcl_ded_code_23() + "," +	// PEG-EXCL-DED-CODE-23	
//					edm.getExcl_ded_code_24() + "," +	// PEG-EXCL-DED-CODE-24		
//					edm.getExcl_ded_code_25() + "," +	// PEG-EXCL-DED-CODE-25
//					edm.getExcl_ded_code_26() + "," +	// PEG-EXCL-DED-CODE-26
//					edm.getExcl_ded_code_27() + "," +	// PEG-EXCL-DED-CODE-27					
//					edm.getExcl_ded_code_28() + "," +	// PEG-EXCL-DED-CODE-28					
//					edm.getExcl_ded_code_29() + "," +	// PEG-EXCL-DED-CODE-29					
//					edm.getExcl_ded_code_30() + "," +	// PEG-EXCL-DED-CODE-30				
					"," +								// PEG-EXCL-DED-CODE-01
					"," +								// PEG-EXCL-DED-CODE-02	
					"," +								// PEG-EXCL-DED-CODE-03	
					"," +								// PEG-EXCL-DED-CODE-04	
					"," +								// PEG-EXCL-DED-CODE-05
					"," +								// PEG-EXCL-DED-CODE-06
					"," +								// PEG-EXCL-DED-CODE-07	
					"," +								// PEG-EXCL-DED-CODE-08	
					"," +								// PEG-EXCL-DED-CODE-09	
					"," +								// PEG-EXCL-DED-CODE-10	
					"," +								// PEG-EXCL-DED-CODE-11
					"," +								// PEG-EXCL-DED-CODE-12	
					"," +								// PEG-EXCL-DED-CODE-13	
					"," +								// PEG-EXCL-DED-CODE-14	
					"," +								// PEG-EXCL-DED-CODE-15
					"," +								// PEG-EXCL-DED-CODE-16
					"," +								// PEG-EXCL-DED-CODE-17	
					"," +								// PEG-EXCL-DED-CODE-18	
					"," +								// PEG-EXCL-DED-CODE-19	
					"," +								// PEG-EXCL-DED-CODE-20	
					"," +								// PEG-EXCL-DED-CODE-21
					"," +								// PEG-EXCL-DED-CODE-22	
					"," +								// PEG-EXCL-DED-CODE-23	
					"," +								// PEG-EXCL-DED-CODE-24	
					"," +								// PEG-EXCL-DED-CODE-25
					"," +								// PEG-EXCL-DED-CODE-26
					"," +								// PEG-EXCL-DED-CODE-27	
					"," +								// PEG-EXCL-DED-CODE-28	
					"," +								// PEG-EXCL-DED-CODE-29	
					"," +								// PEG-EXCL-DED-CODE-30	
	
					edm.getNet_claim_amt()  + "," +		// EDM-NET-CLAIM-AMT
					edm.getPrescribedarea() + "," +		// EDM-PRESCRIBEDAREA
					edm.getStudent_pen_ex()	+ "," +		// EDM-STUDENT-PEN-EX
					edm.getTd1_filing_dat()	+ "," +		// EDM-TD1-FILING-DAT
					edm.getTax_exempt_flg()	+ "," +		// EDM-TAX-EXEMPT-FLG
					edm.getAuth_tax_cred()	+ "," +		// EDM-AUTH-TAX-CRED
					edm.getAuth_tax_ded()	+ "," +	 	// EDM-AUTH-TAX-DED
					edm.getMarried_equiv() 	+ "," +		// EDM-MARRIED-EQUIV
					edm.getAge_65_over()	+ "," +	 	// EDM-AGE-65-OVER
					edm.getEmp_disability()	+ "," +		// EDM-EMP-DISABILITY
					edm.getDep_under_18()	+ "," +		// EDM-DEP-UNDER-18
					edm.getDep_dis_ovr_17()	+ "," +		// EDM-DEP-DIS-OVR-17
					edm.getApproved_stock()	+ "," +	 	// EDM-APPROVED-STOCK
                    "," +                               // RgpApprovedStockPr
					edm.getTax_code()		+ "," +		// EDM-TAX-CODE
					edm.getTax_basis()		+ "," +		// EDM-TAX-BASIS
					edm.getNi_code()		+ "," +		// EDM-NI-CODE
					edm.getDirector()		+ "," +		// EDM-DIRECTOR
					edm.getContracted_out()	+ "," +		// EDM-CONTRACTED-OUT
					edm.getDed_arrs_td()	+ "," +	 	// PEG-DED-ARRS-TD
					edm.getExempt_arrs_td()	+ "," +	    // PEG-EXEMPT-ARRS-TD
//					edm.getRemit_to_code()	+ "," +	 	// PEG-REMIT-TO-CODE
					"," +							 	// PEG-REMIT-TO-CODE - Must be blank if Vendor not used
					"," +								// EDM-TOT-CLAIM-AMT-FLAG
					"," +								// EDM-NON-IND-CL-AMT
 					"," +								// EDM-TRANS-YTD-WAGE
					"," +								// EDM-TRANS-YTD-TAX
					"," +								// EDM-TRANS-YEAR
                    edm.getChfee_override()	+ "," +	 	// PEG-CH-FEE-OVERRIDE
					"," +								// PEG-CH-FEE     ?????
					edm.getFips_code() + "," +	 			// PEG-FIPS-CODE
					"," +								// RPG-CLAIM-CODE - N/A
					edm.getDed_from_garn()	+ "," +	 	// PEG-DED-FROM-GARN
					","  								// RPG-RES-COUNTRY-CODE - N/A
//														// RGP-AZ-FORMULA-NBR - N/A

						);	

		 }		
	public void fileCleanup() throws IOException {
		errReport.flush();
		errReport.close();
		output.flush();
		output.close();
		errOutput.flush();
		errOutput.close();
	}

}


